<div id="headline">AOCRM login</div><br>
<form id="loginform" name="loginform" action="login.php" method="POST">
  <table>
    <tr>
      <td>
        Username
      </td>
      <td>
        <input type="text" name="username">
      </td>
    </tr>
    <tr>
      <td>
        Password
      </td>
      <td>
        <input type="password" name="password">
      </td>
    </tr>
    <tr>
      <td>
        &nbsp;
      </td>
      <td>
        <input type="submit" id="btn_submit" value="Login">
      </td>
    </tr>
  </table>
</form>

<div id="log">
</div>

<script type="text/javascript" language="javascript">
  $( "#loginform" ).submit( function( event ) {
    event.preventDefault();
    var formuser = $( "#loginform" ).find( "input[name='username']" ).val();
    var formpass = $( "#loginform" ).find( "input[name='password']" ).val();
    var request = $.ajax({
      url: "login.php",
      type: "POST",
      data: { username: formuser, password: formpass },
      dataType: "script"
    });
    request.done( function( msg ) {
      msg;
    });
    request.fail( function( jqXHR, textStatus ) {
      $( "#log" ).html( "Request failed: " + textStatus );
    });
    $('#loginform').each ( function(){
      this.reset();
    });
  });
</script>
